#!/bin/bash
SQL="

UPDATE  ftp_vsp_merchant_history_bbw fvm
    SET fvm.close_date = '#yesterday'
WHERE   fvm.id  IN
(
    SELECT  v2.id    FROM     (
        SELECT
            id ,
            merchant_no
        FROM
            ftp_vsp_merchant_history_bbw fvm
        WHERE
            folder_date = '#currentDay'
            AND fvm.acct_branch_bank NOT LIKE '%北部湾银行%'
            AND fvm.acct_branch_bank NOT LIKE '%北部湾村镇银行%'
        ) v2
    LEFT JOIN (
        SELECT
            merchant_no
        FROM
            ftp_vsp_merchant_history_bbw fvm
        WHERE
            folder_date = '#yesterday'
            AND fvm.acct_branch_bank NOT LIKE '%北部湾银行%'
            AND fvm.acct_branch_bank NOT LIKE '%北部湾村镇银行%'
        ) v1 ON
    v1.merchant_no = v2.merchant_no
)
"